package com.gzz.reflectdemo;


import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

/**
 * @author higmd
 */
public class ReflectInvoke {
    public static void main(String[] args) throws Exception {
//        Class<?> clazz = Class.forName("com.gzz.reflectdemo.Student");
//        Object obj = clazz.getDeclaredConstructor().newInstance();
//        clazz.getMethod("show", String.class)
//                .invoke(obj, "张三");
        //
        Class<?> clazz = Student.class;
        Object obj = Map.of("age", 33, "name", "张三");
        Method staticMethod = clazz.getMethod("staticShow", Object.class);
        staticMethod.invoke(null, obj);
        TestServie serv = new TestServie();
        Map<String,Object> obj3 = new HashMap<>();
        obj3.put("name", "张三");
        obj3.put("age", 33);
        serv.handleName(obj3);
        System.out.println(obj3.get("name"));
    }
}
